import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { map, Observable } from 'rxjs';

@Injectable()
export class FormatterInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
    // 格式化响应数据
    const doMap = map((data) => {
      return {
        code: 200,
        message:'成功',
        result: data
      }
    })
    return next.handle().pipe(doMap);
  }
}
